package com.takeshequ.feeds;

import net.tsz.afinal.FinalBitmap;
import android.content.Context;
import android.content.Intent;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.takeshequ.Constants;
import com.takeshequ.R;
import com.takeshequ.chat.ExpressionUtil;
import com.takeshequ.homepage.HomePageActivity;

public class ContentItem2 implements ListItems {

	private Comment comment;

	public ContentItem2(Comment item) {
		this.comment = item;
	}

	public Comment getComment() {
		return comment;
	}

	public void setComment(Comment comment) {
		this.comment = comment;
	}

	@Override
	public int getLayout() {
		return R.layout.feeds_detail_comment;
	}

	@Override
	public boolean isClickable() {
		return false;
	}

	@Override
	public View getView(final Context context, View convertView,
			LayoutInflater inflater) {
		convertView = inflater.inflate(getLayout(), null);
		TextView nickName = (TextView) convertView
				.findViewById(R.id.feeds_comment_nickName);
		nickName.setText(comment.getNickName());
		TextView contentTextView = (TextView) convertView
				.findViewById(R.id.feeds_detail_content);
		SpannableString spannableString = ExpressionUtil.getExpressionString(
				context, comment.getCont());
		contentTextView.setText(spannableString);
		ImageView imageView = (ImageView) convertView
				.findViewById(R.id.feeds_comment_head_img);
		FinalBitmap.create(context).display(imageView, comment.getHeadImage());
		imageView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Constants.selectMemberId=comment.getMemberId();
				context.startActivity(new Intent(context,HomePageActivity.class));
			}
		});
		TextView timeTextView=(TextView)convertView.findViewById(R.id.feeds_comment_time);
		timeTextView.setText(comment.getCommentDateString());
		return convertView;
	}
}
